// Copyright (c) 2025 Huawei Technologies Co., Ltd.
// openUBMC is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//         http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.
//
// Description: 系统启动项设置

#ifndef BOOT_OPTION_MANAGER_HPP
#define BOOT_OPTION_MANAGER_HPP

#include <cstdint>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <stdexcept>
#include "KvmClient.hpp"


class BootOptionManager {
private:
    std::pair<int, std::vector<uint8_t>> SendGetBootOptionReq(const std::vector<uint8_t>& body);
    void RecvGetBootOptionRsp(const std::vector<uint8_t>& body);
    std::pair<int, std::vector<uint8_t>> SendSetBootOptionReq(const std::vector<uint8_t>& body);
    void RecvSetBootOptionRsp(const std::vector<uint8_t>& body);

public:
    explicit BootOptionManager(KvmClient& client);
    ~BootOptionManager();

    KvmClient& client_;
    std::mutex getBootOptionMutex_; // 防止查询启动项重入
    std::mutex setBootOptionMutex_; // 防止设置启动项重入
    std::condition_variable getBootOptionCv_;
    std::condition_variable setBootOptionCv_;
    uint8_t getBootOptionRsp_; // 0xff表示失败后的无效值
    uint8_t setBootOptionRsp_;
};

#endif // BOOT_OPTION_MANAGER_HPP